<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    @ok="submitForm"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="close"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <j-form-container :disabled="formDisabled">
        <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
          <a-row>
            <a-col :span="24">
              <a-form-model-item label="充值钻石" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="changeDiamond">
                <a-input-number :min="0" :max="9999999" style="width: 100%" v-model="model.changeDiamond" placeholder="请输入充值钻石"  ></a-input-number>
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </j-form-container>
    </a-spin>
  </j-modal>
</template>

<script>
import { postAction } from '@/api/manage'
import { duplicateCheck } from '@/api/api'
export default {
  name: 'AddUserGoldNum',
  data () {
    return {
      title:'钻石充值',
      width:800,
      visible: false,
      disableSubmit: false,
      model:{
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      validatorRules: {
        changeDiamond: [
          { required: true, message: '请输入充值钻石'},
        ],
      },
    }
  },
  methods: {
    //打开
    open (record) {
      this.visible=true,
      this.model = Object.assign({}, record)
    },
    //关闭
    close () {
      this.visible = false;
    },
    //提交
    submitForm () {
      const that = this;
      // 触发表单验证
      this.$refs.form.validate(valid => {
        if (valid) {
          that.confirmLoading = true;
          postAction("/user/diamondDetail/webAddDiamondNum",this.model).then((res)=>{
            if(res.success){
              that.$message.success(res.message);
              that.$emit('ok');
              that.close();
            }else{
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.confirmLoading = false;
          })
        }

      })
    },
  }
}
</script>

<style scoped>

</style>